package org.dtrd.modules.record.entity.po;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;

import java.util.Date;

import lombok.Data;
import org.dtrd.modules.record.entity.bean.SugarValuePhotoDetail;


/**
 * <p>
 * 血糖记录表
 * </p>
 *
 * @author xiao
 * @since 2022-07-25
 */
@Data
@TableName("dtrd_ent_rd_signin_sugar_value_photo")
public class DtrdEntRdSigninSugarValuePhoto {

    @TableId(value = "data_id", type = IdType.AUTO)
    private Integer dataId;

    @TableField("patient_id")
    private Integer patientId;

    @TableField("record_date")
    private Date recordDate;

    @TableField("record_time")
    private Date recordTime;

    /**
     * 照片以 , 拼接
     */
    @TableField("record_photo")
    private String recordPhoto;

    @TableField("sugar_value_remark")
    private String sugarValueRemark;

    @TableField("create_time")
    private Date createTime;

    @TableField("is_del")
    @TableLogic
    private Integer isDel;

    public DtrdEntRdSigninSugarValuePhoto init() {
        createTime = new Date();
        isDel = 0;
        return this;
    }

    public DtrdEntRdSigninSugarValuePhoto parseFromDto(SugarValuePhotoDetail dto) {
        dataId = dto.getDataId();
        patientId = dto.getPatientId();
        recordDate = dto.getRecordDate();
        if (recordDate == null) {
            recordDate = new Date();
        }
        recordTime = dto.getRecordTime();
        if (recordTime == null) {
            recordTime = new Date();
        }
        recordPhoto = dto.getRecordPhoto();
        sugarValueRemark = dto.getSugarValueRemark();
        return this;
    }


}
